package cz.muni.fi.pa165.musiclibrary.musiclibraryws.converter;

import java.util.ArrayList;
import java.util.List;

import cz.muni.fi.pa165.musiclibrary.api.service.dto.IArtistDTO;
import cz.muni.fi.pa165.musiclibrary.api.service.dto.IGenreDTO;
import cz.muni.fi.pa165.musiclibrary.musiclibraryws.WSArtist;
import cz.muni.fi.pa165.musiclibrary.musiclibraryws.WSGenre;

/**
 *
 * @author Maros Kucbel
 * @date 2012-12-07T22:17:15+0100
 */
public final class WSConverter {
    
    public static WSGenre convertToWSGenre(final IGenreDTO genreDto) {
        WSGenre genre = new WSGenre();
        genre.setIdGenre(genreDto.getIdGenre());
        genre.setName(genreDto.getName());
        return genre;
    }
    
    public static List<WSGenre> convertToWSGenres(final List<IGenreDTO> genreDtos) {
        List<WSGenre> genres = new ArrayList<WSGenre>(genreDtos.size());
        for (IGenreDTO genreDto : genreDtos) {
            genres.add(convertToWSGenre(genreDto));
        }
        return genres;
    }
    
    public static IGenreDTO convertFromWSGenre(final WSGenre genre) {
        IGenreDTO genreDto = DTOFactory.create(IGenreDTO.class);
        genreDto.setIdGenre(genre.getIdGenre());
        genreDto.setName(genre.getName());
        return genreDto;
    }
    
    public static WSArtist convertToWSArtist(final IArtistDTO artistDto) {
        WSArtist artist = new WSArtist();
        artist.setIdArtist(artistDto.getIdArtist());
        artist.setName(artistDto.getName());
        artist.setDescription(artistDto.getDescription());
        return artist;
    }
    
    public static List<WSArtist> convertToWSArtists(final List<IArtistDTO> artistDtos) {
        List<WSArtist> artists = new ArrayList<WSArtist>(artistDtos.size());
        for (IArtistDTO artistDto : artistDtos) {
            artists.add(convertToWSArtist(artistDto));
        }
        return artists;
    }
    
    public static IArtistDTO convertFromWSArtist(final WSArtist artist) {
        IArtistDTO artistDto = DTOFactory.create(IArtistDTO.class);
        artistDto.setIdArtist(artist.getIdArtist());
        artistDto.setName(artist.getName());
        artistDto.setDescription(artist.getDescription());
        return artistDto;
    }
    
    
}